package com.base.cn.platform.os.service.course.cou.buy;

import com.base.cn.platform.os.entity.course.cou.buy.CourseBuyRecord;
import com.base.cn.platform.os.entity.course.cou.buy.CourseBuyRecordExpand;
import com.base.cn.platform.os.service.FeignAuthConfig;
import com.base.cn.platform.os.service.course.CourseBaseService;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * 课程购买记录接口
 *
 * @author s.li
 * @create 2018-05-17-17:58
 */
@FeignClient(name = CourseBaseService.appName,configuration = FeignAuthConfig.class)
public interface CourseBuyRecordService extends CourseBaseService {

    /**
     * 获取用户课程数据
     * @return  Map<String,Integer>
     */
    @RequestMapping(contextPath + "/getUserCourseNum")
    Map<String,Integer> getUserCourseNum(@RequestParam("userId") BigDecimal userId);

    /**
     * 检测用户是否购买过该课程
     * @param userId
     * @param courseId
     * @return CourseBuyRecord 返回null则未购买过
     */
    @RequestMapping(contextPath + "/checkUserBuyCourse")
    Map<String,Object> checkUserBuyCourse(@RequestParam("userId") BigDecimal userId,
                                          @RequestParam("courseId") BigDecimal courseId);
    /**
     * 修改课程过期时间
     * @param detailsId
     * @param validTime
     */
    @RequestMapping(contextPath + "/updateCourseBuyRecordValidTime")
    Map<String,Object> updateCourseBuyRecordValidTime(@RequestParam("detailsId") BigDecimal detailsId,
                                                      @RequestParam("validTime") String validTime);

    /**
     * 保存课程购买记录
     * @param courseBuyRecordList
     */
    @RequestMapping(contextPath + "/createCourseBuyRecord")
    void createCourseBuyRecord(@RequestBody List<Map<String, Object>> courseBuyRecordList);

    /**
     * 通过流水ID，修改课程购买记录状态
     * @param detailsId 流水ID
     * @param courseStatus  课程状态，SUCCESS可使用，REFUND退费，CLOSE关闭
     * @return Map<String,Object>
     */
    @RequestMapping(contextPath + "/updateRecordCourseStatusByDetailsId")
    Map<String,Object> updateRecordCourseStatusByDetailsId(@RequestParam("detailsId") BigDecimal detailsId,
                                                           @RequestParam("courseStatus") String courseStatus);

    /**
     * 通过订单ID，修改课程购买记录的状态
     * @param orderId 订单ID
     * @param courseStatus 课程状态，SUCCESS可使用，REFUND退费，CLOSE关闭
     */
    @RequestMapping(contextPath + "/updateRecordCourseStatus")
    Map<String,Object> updateRecordCourseStatus(@RequestParam("orderId") BigDecimal orderId,
                                                @RequestParam("courseStatus") String courseStatus);

    /**
     * 分页查询用户购买记录
     * @param courseBuyRecord 查询条件
     * @param currentPage 当前码
     * @param pageSize 页面显示数量
     * @param setCourseData 是否设置课程
     * @param setTeacherData 是否设置课程老师数据
     * @param setProfileData 是否设置课程扩展数据
     * @param setStudySpeed 是否设置学习进度
     * @param setStudySumTime 是否设置总学习时间
     * @param setWeekStudyTime 是否设置一周的学习时间
     * @param setLastStudyCatalog 是否设置最后一个学习的目录
     * @return PageInfo<CourseBuyRecord>
     */
    @RequestMapping(contextPath + "/findCourseBuyRecordPage")
    Map<String,Object> findCourseBuyRecordPage(@RequestBody Map<String, Object> courseBuyRecord,
                                               @RequestParam(value = "currentPage", required = false, defaultValue = "1") int currentPage,
                                               @RequestParam(value = "pageSize", required = false, defaultValue = "10") int pageSize,
                                               @RequestParam("setCourseData") boolean setCourseData,
                                               @RequestParam("setTeacherData") boolean setTeacherData,
                                               @RequestParam("setProfileData") boolean setProfileData,
                                               @RequestParam("setStudySpeed") boolean setStudySpeed,
                                               @RequestParam("setStudySumTime") boolean setStudySumTime,
                                               @RequestParam("setWeekStudyTime") boolean setWeekStudyTime,
                                               @RequestParam("setLastStudyCatalog") boolean setLastStudyCatalog);

    /**
     * 查询课程购买记录（不分页）
     * @param courseBuyRecord 查询条件
     * @param setCourseData 是否设置课程
     * @return
     */
    @RequestMapping(contextPath + "/findCourseBuyRecordList")
    List<Map<String, Object>> findCourseBuyRecordList(@RequestBody Map<String, Object> courseBuyRecord,
                                                      @RequestParam("setCourseData") boolean setCourseData);

    /**
     * 查询课程购买记录Map
     * @param courseBuyRecord 查询条件
     * @param setCourseData 是否设置课程
     * @return Map<BigDecimal,List<CourseBuyRecord>>,课程ID为Ke
     */
    @RequestMapping(contextPath + "/findCourseBuyRecordMap")
    Map<BigDecimal,List<CourseBuyRecord>> findCourseBuyRecordMap(@RequestBody CourseBuyRecord courseBuyRecord,
                                                                        @RequestParam("setCourseData") boolean setCourseData);

    /**
     * 获取用户的购买列表，一般用于验证数据
     * @param courseBuyRecord 查询条件对象
     * @param setCourseData 是否设置课程数据
     * @return List<CourseBuyRecord>
     */
    @RequestMapping(contextPath + "/findCourseBuyRecordByUserId")
    List<Map<String, Object>> findCourseBuyRecordByUserId(@RequestBody Map<String, Object> courseBuyRecord,
                                                          @RequestParam("setCourseData") boolean setCourseData);
    /**
     * 获取播放的购买记录
     * @param id 记录ID
     * @return CourseBuyRecord
     */
    @RequestMapping(contextPath + "/findPlayCourseBuyRecordById")
    Map<String,Object> findPlayCourseBuyRecordById(@RequestParam("id") BigDecimal id);

    /**
     * 通过ID获取购买记录
     * @param id 记录ID
     * @param userId 用户ID
     * @param setCourseData 是否设置套餐数据
     * @param setPackageCourseData 是否设置套餐下课程课程数据（套餐类型的记录才起作用）
     * @return CourseBuyRecord
     */
    @RequestMapping(contextPath + "/findCourseBuyRecordById")
    Map<String,Object> findCourseBuyRecordById(@RequestParam("id") BigDecimal id,
                                               @RequestParam("userId") BigDecimal userId,
                                               @RequestParam("setCourseData") boolean setCourseData,
                                               @RequestParam("setPackageCourseData") boolean setPackageCourseData);

    /**
     * 通过ID获取套餐的激活数据
     * @param id 记录ID
     * @param userId 用户ID
     * @return CourseBuyRecord
     */
    @RequestMapping(contextPath + "/findPackageActivationById")
    Map<String,Object> findPackageActivationById(@RequestParam("id") BigDecimal id,
                                                 @RequestParam("userId") BigDecimal userId);

    /***
     * 激活套餐
     * @param userId 用户ID
     * @param recordId 购买记录ID
     * @param courseIds 购买套餐下要激活的课程ID串
     * @return Map<String,Object>
     */
    @RequestMapping(contextPath + "/activationPackage")
    Map<String,Object> activationPackage(@RequestParam("userId") BigDecimal userId,
                                         @RequestParam("recordId") BigDecimal recordId,
                                         @RequestParam("courseIds") String courseIds);
    /**
     * 通过流水ID获取购买记录
     * @param detailsId 记录ID
     * @param setCourseData 是否设置课程数据
     * @return CourseBuyRecord
     */
    @RequestMapping(contextPath + "/findCourseBuyRecordByDetailsId")
    Map<String,Object> findCourseBuyRecordByDetailsId(@RequestParam("detailsId") BigDecimal detailsId,
                                                      @RequestParam("setCourseData") boolean setCourseData);

    /**
     * 更新记录状态，用于套餐手动激活
     * @param id 记录ID
     * @param status 状态，0未激动，1已激活
     * @param courseIds 课程ID串
     */
    @RequestMapping(contextPath + "/updateCourseBuyRecordStatus")
    Map<String,Object> updateCourseBuyRecordStatus(@RequestParam("id") BigDecimal id,
                                                   @RequestParam("userId") BigDecimal userId,
                                                   @RequestParam("status") int status,
                                                   @RequestParam("courseIds") String courseIds);


    /**
     * 分页查询用户购买记录（用于前台）
     * @param courseBuyRecord 查询条件
     * @param currentPage 当前码
     * @param pageSize 页面显示数量
     * @param setCourseData 是否设置课程
     * @param setTeacherData 是否设置课程老师数据
     * @param setProfileData 是否设置课程扩展数据
     * @param setStudySpeed 是否设置学习进度
     * @param setStudySumTime 是否设置总学习时间
     * @param setWeekStudyTime 是否设置一周的学习时间
     * @param setLastStudyCatalog 是否设置最后一个学习的目录
     * @return PageInfo<CourseBuyRecord>
     */
    @RequestMapping(contextPath + "/findCourseBuyRecordFrontPage")
    Map<String,Object> findCourseBuyRecordFrontPage(@RequestBody Map<String, Object> courseBuyRecord,
                                                    @RequestParam(value = "currentPage", required = false, defaultValue = "1") int currentPage,
                                                    @RequestParam(value = "pageSize", required = false, defaultValue = "10") int pageSize,
                                                    @RequestParam("setCourseData") boolean setCourseData,
                                                    @RequestParam("setTeacherData") boolean setTeacherData,
                                                    @RequestParam("setProfileData") boolean setProfileData,
                                                    @RequestParam("setStudySpeed") boolean setStudySpeed,
                                                    @RequestParam("setStudySumTime") boolean setStudySumTime,
                                                    @RequestParam("setWeekStudyTime") boolean setWeekStudyTime,
                                                    @RequestParam("setLastStudyCatalog") boolean setLastStudyCatalog);



    /**
     * 分页查询用户购买记录（用于前台）
     * @param courseBuyRecordExpand 查询条件
     * @param currentPage 当前码
     * @param pageSize 页面显示数量
     * @return PageInfo<CourseBuyRecord>
     */
    @RequestMapping(contextPath + "/findCourseBuyRecordLearnPage")
    Map<String,Object> findCourseBuyRecordLearnPage(@RequestBody CourseBuyRecordExpand courseBuyRecordExpand,
                                                    @RequestParam(value = "currentPage", required = false, defaultValue = "1") int currentPage,
                                                    @RequestParam(value = "pageSize", required = false, defaultValue = "10") int pageSize);

}
